package com.example.backetballgame.gui;

import com.example.backetballgame.store.StoreManage;

import javax.swing.*;
import java.awt.*;

public class SeasonEndFrame extends JFrame {

    public SeasonEndFrame() {
        // Set page title
        setTitle("Season End");

        // Set page size and position
        setSize(800, 600);
        setLocationRelativeTo(null);

        // Create page layout
        JPanel mainPanel = new JPanel(new BorderLayout());
        JPanel centerPanel = new JPanel(new GridLayout(3, 1));
        JPanel teamNamePanel = new JPanel();
        JPanel attributesPanel = new JPanel(new GridLayout(4, 1));
        JPanel rewardsPanel = new JPanel(new GridLayout(2, 2));
        JPanel againButtonPanel = new JPanel();

        // Create page elements
        JLabel titleLabel = new JLabel("Season End");
        titleLabel.setFont(new Font("微软雅黑", Font.PLAIN, 36));
        titleLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JLabel teamNameLabel = new JLabel("Team "+ StoreManage.getTeamName());
        teamNameLabel.setFont(new Font("微软雅黑", Font.PLAIN, 60));
        teamNameLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JLabel attribute1Label = new JLabel("Attribute 1: xxxx");
        JLabel attribute2Label = new JLabel("Attribute 2: xxxx");
        JLabel attribute3Label = new JLabel("Attribute 3: xxxx");
        JLabel attribute4Label = new JLabel("Attribute 4: xxxx");
        attribute1Label.setFont(new Font("微软雅黑", Font.PLAIN, 24));
        attribute2Label.setFont(new Font("微软雅黑", Font.PLAIN, 24));
        attribute3Label.setFont(new Font("微软雅黑", Font.PLAIN, 24));
        attribute4Label.setFont(new Font("微软雅黑", Font.PLAIN, 24));
        attributesPanel.add(attribute1Label);
        attributesPanel.add(attribute2Label);
        attributesPanel.add(attribute3Label);
        attributesPanel.add(attribute4Label);

        JLabel amountLabel = new JLabel("Winning amount: xxxx yuan");
        amountLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
        amountLabel.setForeground(Color.RED);
        amountLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JLabel pointLabel = new JLabel("Winning points: xxxx");
        pointLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
        pointLabel.setForeground(Color.RED);
        pointLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JLabel rewardsLabel = new JLabel("This is the amount and points you won in this season");
        rewardsLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
        rewardsLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JButton againButton = new JButton("Play Again");
        againButton.setFont(new Font("微软雅黑", Font.PLAIN, 14));
        againButton.setBackground(Color.RED);
        againButton.setForeground(Color.black);
        againButton.addActionListener(event ->{
            dispose();
            new WelcomeFrame();
        });

        // Add page elements tothe layout
         teamNamePanel.add(teamNameLabel); centerPanel.add(teamNamePanel);
         centerPanel.add(attributesPanel);
         centerPanel.add(rewardsPanel); rewardsPanel.add(amountLabel);
         rewardsPanel.add(pointLabel); rewardsPanel.add(rewardsLabel);
         againButtonPanel.add(againButton);
         mainPanel.add(titleLabel, BorderLayout.NORTH);
         mainPanel.add(centerPanel, BorderLayout.CENTER);
         mainPanel.add(againButtonPanel, BorderLayout.SOUTH);

            // Add the layout to the page
            add(mainPanel);

            // Set the visibility of the page
            setVisible(true);
        }

        public static void main(String[] args) {
            new SeasonEndFrame();
        }
        }